package com.jinbo.footmessage.httpretrofit;

import retrofit.RestAdapter;


public class HttpProtocolFactory {


    public final static String HOST_URL_USER ="http://120.27.122.1:8080/FS";//"; //"http://110.65.92.78:8084/FS/";

   // private static final Map<String, Object> sHttpProtocolMap = new ConcurrentHashMap<String, Object>();


    public static <T> T getProtocol(String host, Class<T> clazz) {
       /* if (sHttpProtocolMap.containsKey(clazz.getName())) {
            return (T) sHttpProtocolMap.get(clazz.getName());
        }*/

        //Client client = new OkClient();
        RestAdapter restAdapter = new RestAdapter.Builder()
                //.setClient(client)
                .setEndpoint(host)
               // .setErrorHandler(new MyErrorHandler())
               // .setRequestInterceptor(new MyRequestInterceptor())
            /*    .setLogLevel(
                        BaseApplication.DEBUG ? RestAdapter.LogLevel.FULL
                                : RestAdapter.LogLevel.NONE)*/
                                .build();
        T t = restAdapter.create(clazz);
      //  sHttpProtocolMap.put(clazz.getName(), t);
        return t;
    }

/*    private static class MyErrorHandler implements ErrorHandler {

        @Override
        public Throwable handleError(RetrofitError cause) {
            return new ClientException(cause);
        }
    }

    private static class MyRequestInterceptor implements RequestInterceptor {
        @Override
        public void intercept(RequestFacade request) {
            request.addHeader("User-Agent", "Client-Android");
        }
    }*/

}
